package com.landary.parameterrplacement.webservice;

import org.springframework.stereotype.Component;

import javax.xml.rpc.ServiceException;
import javax.xml.rpc.Stub;
import java.rmi.RemoteException;

/**
 * @author 刘欣
 * @createTime 2023/8/9 17:41
 * @description
 */
@Component
public class UUMS_ServiceProxy implements UUMS_Service {
    @Override
    public String UUMS_SEND_GetSubPerson_Service(String reqMsg) throws RemoteException {
        if (uUMS_Service == null) {
            _initUUMS_ServiceProxy();
        }
        return uUMS_Service.UUMS_SEND_GetSubPerson_Service(reqMsg);
    }

    @Override
    public String UUMS_SEND_GetSubDepartment_Service(String reqMsg) throws RemoteException {
        if (uUMS_Service == null) {
            _initUUMS_ServiceProxy();
        }
        return uUMS_Service.UUMS_SEND_GetSubDepartment_Service(reqMsg);
    }

    private String _endpoint = null;
    private UUMS_Service uUMS_Service = null;

    public UUMS_ServiceProxy() {
        _initUUMS_ServiceProxy();
    }

    public UUMS_ServiceProxy(String endpoint) {
        _endpoint = endpoint;
        _initUUMS_ServiceProxy();
    }

    private void _initUUMS_ServiceProxy() {
        try {
            uUMS_Service = (new UUMS_ServiceImplServiceLocator()).getUUMS_ServiceImplport();
            if (uUMS_Service != null) {
                if (_endpoint != null) {
                    ((Stub) uUMS_Service)._setProperty("javax.xml.rpc.service.endpoint.address", _endpoint);
                } else {
                    _endpoint = (String) ((Stub) uUMS_Service)._getProperty("javax.xml.rpc.service.endpoint.address");
                }
            }
        } catch (ServiceException e) {
        }
    }

    public String getEndpoint() {
        return _endpoint;
    }

    public void set_endpoint(String endpoint) {
        _endpoint = endpoint;
        if (uUMS_Service != null) {
            ((Stub) uUMS_Service)._setProperty("javax.xml.rpc.service.endpoint.address", _endpoint);
        }
    }

    public UUMS_Service getUUMS_Service() {
        if (uUMS_Service == null) {
            _initUUMS_ServiceProxy();
        }
        return uUMS_Service;
    }
}
